package com.minjiang.blog.service.impl;

import com.minjiang.blog.mapper.BlogDao;
import com.minjiang.blog.mode.Blog;
import com.minjiang.blog.queryvo.*;
import com.minjiang.blog.service.BlogService;
import com.minjiang.blog.util.MarkdownUtils;
import org.apache.ibatis.javassist.NotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author 60590
 */
@Service
public class BlogServiceImpl implements BlogService{

    @Autowired
    private BlogDao blogDao;

    @Override
    public List<BlogQuery> getAllBlog() {
        return blogDao.getAllBlogQuery();
    }

    @Override
    public Blog getBlogById(Long id) {
        return blogDao.getBlogById(id);
    }

    @Override
    public int saveBlog(Blog blog) {
        blog.setUpdateTime(new Date());
        return blogDao.saveBlog(blog);
    }

    @Override
    public int updateBlog(Blog blog) {
        blog.setUpdateTime(new Date());
        return blogDao.updateBlog(blog);
    }

    @Override
    public int deleteBlog(Long id) {
        return blogDao.deleteBlog(id);
    }

    @Override
    public List<BlogQuery> getBlogBySearch(SearchBlog searchBlog) {
        return blogDao.getBlogBySearch(searchBlog) ;
    }


    @Override
    public Blog getBlogByName(String title) {
        return blogDao.getBlogByName(title);
    }
}
